import React from 'react'

export default class formDemo extends React.Component{
    constructor(props){
        super(props)
        this.state={
            count:1
        }
    }

    changeState=(e)=>{
        this.setState({
            count:e.target.value
        })
        // this.state.count=e.target.value
    }
    valueSubmit=(e)=>{
        // 阻止默认事件
        e.preventDefault()
    }   
    render(){
        return(
            <div>
                <p>这是一个form组件</p>
                 <div>{this.state.count}</div>
                 <form action="" onSubmit={this.valueSubmit}>
                 <input value={this.state.count} onChange={this.changeState} type="text"/>
                 <input type="submit"/>
                 </form>

            </div>
        )
    }
}